import pandas as pd

# 读取 Excel 文件
file_path = 'D:\\箱号.xlsx'
df = pd.read_excel(file_path)

# 假设 Excel 文件中有一列名为 '旧盒号'
if '旧盒号' in df.columns:
    id_list = df['旧盒号'].astype(str).tolist()

    # 将每个 id 加上单引号
    quoted_id_list = [f"'{id}'" for id in id_list]

    # 构建 DELETE 语句
    if quoted_id_list:
        delete_query = f"SELECT * FROM fa_pack WHERE box IN ({', '.join(quoted_id_list)})"
        print(delete_query)
    else:
        print("No IDs found to delete.")
else:
    print("Column '旧盒号' not found in the Excel file.")